<?php

namespace App\Services;

use App\Models\IntegralRatio;

class IntegralRatioService extends BaseService
{

    public $IntegralRatio;

    public function __construct()
    {
        $this->IntegralRatio = new IntegralRatio();
    }


    /**
     * 2021/3/15--9:03
     * @param int $limit
     * @param bool $if_paginate
     * @param bool $if_code_return
     * @return array
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:getList
     * @effect:获取抵扣列表
     */
    public function getList($limit = 30, $if_paginate = true, $if_code_return = true)
    {
        $where = [];
        if (request()->is_show) {
            $where['is_show'] = 0;
        }
        $object = $this->IntegralRatio->where($where);
        if (\request()->keywords) {
            $object->where('name', \request()->keywords);
        }
        if ($if_paginate) {
            $list = $object->orderBy('sort', 'desc')->paginate($limit)->toArray();
        } else {
            $list = $object->orderBy('sort', 'desc')->select()->get()->toArray();
        }
        if ($if_code_return) {
            return $this->success($list);
        } else {
            return $this->format($list);
        }
    }


    /**
     * 2021/3/15--9:04
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:add
     * @effect:添加积分抵扣
     */
    public function add()
    {

    }

    /**
     * 2021/3/15--9:04
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:edit
     * @effect:修改积分抵扣
     */
    public function edit()
    {

    }

    /**
     * 2021/3/15--9:05
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:del
     * @effect:删除积分抵扣
     */
    public function del()
    {

    }


    /**
     * 2021/3/15--9:06
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:edit_disable
     * @effect:修改积分列表
     */
    public function edit_disable()
    {

    }


    public function __destruct()
    {
        $this->IntegralRatio;
        // TODO: Implement __destruct() method.
    }
}
